package com.example.spzx.controller;

import com.example.spzx.Service.CategoryBrandService;
import com.example.spzx.model.entity.product.CategoryBrand;
import com.example.spzx.model.vo.common.Result;
import com.example.spzx.model.vo.common.ResultCodeEnum;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/product/categoryBrand")
@RestController
public class CategoryBrandController {
    @Resource
    private CategoryBrandService service;
    @GetMapping("/{page}/{limit}")
    public Result<CategoryBrand> getlist(@PathVariable("page") Integer page,@PathVariable("limit") Integer limit, Integer brandId, Integer categoryId){
        PageInfo<CategoryBrand> pageInfo=service.getlist(page,limit, brandId,categoryId);
        return Result.build(pageInfo, ResultCodeEnum.SUCCESS);

    }
    @PostMapping("/save")
    public Result<CategoryBrand> save(@RequestBody CategoryBrand categoryBrand){
        service.add(categoryBrand);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @PutMapping("/updateById")
    public Result<CategoryBrand> updateById(@RequestBody CategoryBrand categoryBrand){
        service.updateById(categoryBrand);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") Integer id){
        service.delete(id);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }


}
